package ThreadDemo1;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 故我
 * Date: 2023-10-15
 * Time: 21:01
 */
public class ThreadDemo25 {
    public static void main(String[] args) {
        ExecutorService pool = Executors.newFixedThreadPool(10);//线程池中有10个线程
        for (int i = 0; i < 1000; i++) {
            int n = i;// 在java中因为 i 是变量，所以不会被捕捉
            pool.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println("hello " + n);
                }
            });
        }
    }
}
